home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 July: Mac OS SDK / Dev.CD Jul 99 SDK1.toast / Development Kits / Mac OS / Telephone Manager / Stiletto Sources / ModuleSources / Alert.c next >
Encoding:
C/C++ Source or Header  |  1995-06-26  |  3.2 KB  |  119 lines  |  [TEXT/MPS ]

  1. /************************************************************************************************/
  2. /*                                                                                                */
  3. /*    Module Name:    Alert                                                                        */
  4. /*                                                                                                */
  5. /*    File Name:        Alert.c                                                                        */
  6. /*                                                                                                */
  7. /*    © Apple Computer, Inc. 1991-1995                                                            */
  8. /*    All Rights Reserved                                                                            */
  9. /*                                                                                                */
  10. /*    Revision History:                                                                            */
  11. /*                                                                                                */
  12. /*        Date        Who                    Modification                                            */
  13. /*                                                                                                */
  14. /*        1991-08-14    Chris Halim            Original version                                        */
  15. /*        1995-06-26    Jaakko Railo        Version 2.0                                                */
  16. /*                                                                                                */
  17. /************************************************************************************************/
  18.  
  19. /****************************************** DESCRIPTION ******************************************
  20.  
  21. *************************************************************************************************/
  22.  
  23. /******************************************** HEADERS *******************************************/
  24.  
  25. #include "TextUtils.h"
  26.  
  27. #include "TestModule.h"
  28.  
  29. /****************************************** DEFINITIONS *****************************************/
  30.  
  31. #define    rGetTwoNumbersDLOG    10000
  32. #define    kNumber1                3
  33. #define    kNumber2                5
  34.  
  35. /****************************************** PROTOTYPES ******************************************/
  36.  
  37. short    GetTwoNumbers (short * , short *);
  38. void     DoTest (CHRSPtr paramPtr);
  39.  
  40. /************************************************************************************************/
  41. /************************************************************************************************/
  42.  
  43.  
  44. pascal short TestModule (CHRSPtr paramPtr)
  45. {
  46.     short    returnValue = noErr;
  47.     
  48.     if (paramPtr->version <= kTestModuleVersion) {
  49.         
  50.         DoTest (paramPtr);
  51.         
  52.     }
  53.     else
  54.         returnValue = kWrongVersion;
  55.         
  56.     return (returnValue);
  57. }
  58.  
  59.  
  60. short    GetTwoNumbers (short * number1, short * number2)
  61. {
  62.     short        itemKind;
  63.     Handle        itemHand;
  64.     Rect        itemRect;
  65.     short        itemHit;
  66.     DialogPtr    theDialog;
  67.     Str255        itemStr;
  68.     long        tlong;
  69.     
  70.     if ((theDialog = GetNewDialog (rGetTwoNumbersDLOG, nil, (WindowPtr)(-1L))) != nil) {
  71.         GetDItem (theDialog, kNumber1, &itemKind, &itemHand, &itemRect);
  72.         SelIText (theDialog, kNumber1, 0, 32767);
  73.         
  74.         ShowWindow (theDialog);
  75.         
  76.         ModalDialog (nil, &itemHit);
  77.         
  78.         if (itemHit == ok) {
  79.             GetDItem (theDialog, kNumber1, &itemKind, &itemHand, &itemRect);
  80.             GetIText (itemHand, itemStr);
  81.             StringToNum (itemStr, &tlong);
  82.             *number1 = tlong;
  83.  
  84.             GetDItem (theDialog, kNumber2, &itemKind, &itemHand, &itemRect);
  85.             GetIText (itemHand, itemStr);
  86.             StringToNum (itemStr, &tlong);
  87.             *number2 = tlong;
  88.         }
  89.         
  90.         DisposeDialog (theDialog);
  91.     }
  92.     else
  93.         itemHit = -1;
  94.     
  95.     return (itemHit);
  96. }
  97.  
  98.  
  99. void DoTest (CHRSPtr paramPtr)
  100. {
  101.     TELHandle    termHand = GetCurrentTELHandle (paramPtr);
  102.     short        itemHit;
  103.     OSErr        errCode;
  104.     short        level, pattern;
  105.     
  106.     if ((itemHit = GetTwoNumbers (&level, &pattern)) == ok) {
  107.         
  108.         if ((errCode = TELAlert (termHand, &level, pattern)) == noErr)
  109.             Print (paramPtr, "TELAlert --> level = %d", level);
  110.         else
  111.             Print (paramPtr, "### TELAlert failed : %d", errCode);
  112.     }
  113.     else
  114.         if (itemHit == -1)
  115.             Print (paramPtr, "### Unable to get a DLOG resource");
  116. }
  117.  
  118.  
  119.